package com.zmc.third.application.impl;

import com.zmc.common.domain.resp.order.RefundResp;
import com.zmc.common.utils.R;
import com.zmc.third.application.PayApplicationService;
import com.zmc.third.infrastructure.bean.resp.PayNotifyResp;
import com.zmc.third.infrastructure.bean.resp.PayQueryResp;
import com.zmc.third.infrastructure.bean.vo.PayCodeVo;
import com.zmc.third.infrastructure.bean.vo.PayQueryVo;
import com.zmc.common.domain.vo.third.PayRefundVo;
import com.zmc.third.application.factory.PayWayFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author：zmc
 * @Date：2024/11/8 21:09
 */

@Component
public class PayApplicationServiceImpl implements PayApplicationService {

    @Autowired
    private PayWayFactory payFactory;


    @Override
    public R getPayChannel(PayCodeVo vo) {
        return payFactory.getPayWay(vo.getType()).getPayChannel(vo.getOrderNo());
    }

    @Override
    public PayQueryResp queryPay(PayQueryVo vo) {
        return payFactory.getPayWay(vo.getType()).queryPayResult(vo.getOrderNo());
    }


    @Override
    public PayNotifyResp payNotify(String payType,  Map<String, String> params) {
        return payFactory.getNotifyWay(payType).notify(params);
    }

    @Override
    public RefundResp payRefund(PayRefundVo vo) {
        return payFactory.getRefundWay(vo.getRefundWay()).refund(vo);
    }

}
